<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<script type="text/javascript">
    $(document).ready(function () {
        $("#submitbutton").click(function () {
        
        /*
        var datastring= "user.uaddress="+$("#user\\.uid").val();
        				"user.ualais="+$("#user\\.ualais").val()+"&"+
        				"user.upassword="+$(" \#user\\.upassword").val() +"&"+
        				"user.uemail="+$("#user\\.uemail").val() +"&"+
        				"user.utel="+$("#user\\.utel").val() +"&"+
        				"user.uaddress="+$("#user\\.uaddress").val();
        				*/
            var options = {
                url: 'updateuserinfor.action',
                type: 'post',
                dataType: 'text',
                data: $("#publishform").serialize(),
                success: function (responsedata) {
                    //if (responsedata.length > 0)
                       // $("#responseText").text(responsedata);
                    $('#myModal').modal('show');
                    if(responsedata=="6"){//登录成功
                    	 function jump(count) { 
                			window.setTimeout(function(){ 
                    			count--; 
                    			if(count > 0) { 
                       				$("#printcontent").html("<p class='bg-success'>用户信息修改成功，将在"+count+"秒后进入首页</p>"); 
                        			jump(count); 
                    			} else { 
                        			location.href="p_index.action"; 
                    			} 
                			}, 1000); 
           				 } 
            		jump(3); 
                    }
                    if(responsedata=="4"){
                    	$("#printcontent").html("<p class='bg-danger'>信息修改失败</p>");
                    }
                }
            };
            $.ajax(options);
            return false;
        });
    });	
    
    $(document).ready(function () {
     var uid = $("#user\\.uid").val();
     var url = "getuserinfo.action?user.uid="+uid;
     $.getJSON(url, function(data) {
        var user=data;
        $("#user\\.ualais").val( (user.ualais==null)?null:user.ualais );
        $("#user\\.uemail").val( (user.uemail==null)?null:user.uemail );
        $("#user\\.uname").val( (user.uname==null)?null:user.uname );
        $("#user\\.utel").val( (user.utel==null)?null:user.utel );
        $("#user\\.uaddress").val( (user.uaddress==null)?null:user.uaddress );
        $("#user\\.uimage").val( (user.uimage==null)?null:user.uimage );
        });
  }); 
</script>
<div class="container">
	<div class="modal fade" id="myModal"  tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
  				<div class="modal-dialog">
     				<div class="modal-content">
        				<div class="modal-header">
           				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                 					×
           				</button>
           				<h4 class="modal-title" id="myModalLabel">提示</h4>
      					</div>
        				<div class="modal-body" id="printcontent"></div>
        				<div class="modal-footer">
           				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        				</div>
     				</div><!-- /.modal-content -->
			</div><!-- /.modal -->
    </div>
	<form role="form" id="publishform">
	  <input id="user.uid" name="user.uid"  type="text" style="display:none;" value=<s:property value="#session.user.uid"/>>
	  <div class="form-group">
	    <label for="user。ualais">用户名</label>
	    <input type="text" class="form-control" id="user.ualais" name="user.ualais" placeholder="">
	  </div>
	    <div class="form-group">
	    <label for="user.upassword">密码</label>
	    <input type="password" class="form-control" id="user.upassword" name="user.upassword" placeholder="Password">
	  </div>
	  <div class="form-group">
	    <label for="user.uemail">电子邮箱</label>
	    <input type="email" class="form-control" id="user.uemail" name="user.uemail" placeholder="Enter email">
	  </div>
	  <div class="form-group">
	    <label for="user.uname">真实姓名</label>
	    <input type="text" class="form-control" id="user.uname" name="user.uname" placeholder="Username">
	  </div>
	  <div class="form-group">
	    <label for="user.utel">电话</label>
	    <input type="text" class="form-control" id="user.utel" name="user.utel" placeholder="">
	  </div>
	  <div class="form-group">
	    <label for="user.uaddress">地址</label>
	    <input type="text" class="form-control" id="user.uaddress" name="user.uaddress" placeholder="">
	  </div>
	  <div class="form-group">
	    <label for="user.uimage">上传头像</label>
	    <input type="file" id="user.uimage" name="user.uimage">
	    <p class="help-block"></p>
 </div>
<!--   <div class="checkbox">
    <label>
      <input type="checkbox"> Check me out
    </label>
  </div> -->
  <button type="submit" id="submitbutton" class="btn btn-default">修改</button>
</form>
</div>